package com.cma.cmabackend.dao;

import com.cma.cmabackend.entity.Project;
import com.cma.cmabackend.entity.Standard;
import com.cma.cmabackend.entity.re.ReProject;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ProjectDao extends JpaRepository<Project, Integer> {

    @Query("select new com.cma.cmabackend.entity.re.ReProject(p.id,p.name,p.labAdmin.username,p.status) from project p where p.status = ?1 or p.status = ?2")
    List<ReProject> findAllByStatus(Project.Status status, Project.Status status1);

    @Query("select new com.cma.cmabackend.entity.re.ReProject(p.id,p.name,p.labAdmin.username,p.status) from project p where p.status = ?1")
    List<ReProject> findAllByState(Project.Status status);

    Project findByStandardsContains(Standard standard);

    @Query("select new com.cma.cmabackend.entity.re.ReProject(p.id,p.name,p.labAdmin.username,p.status) from project p where p.status = ?1 or p.status = ?2 or p.status = ?3")
    List<ReProject> findAllBy3Status(Project.Status status, Project.Status status1, Project.Status status2);
}
